package WeekNight;

import java.util.Arrays;
import java.util.Scanner;

class ArrayUtils {
	public static double findMax(double[] arr, int begin, int end) throws IllegalArgumentException {
		if (begin >= end) {
			throw new IllegalArgumentException("begin:" + begin + " >= " + "end:" + end);
		}
		if (begin < 0) {
			throw new IllegalArgumentException("begin:" + begin + " < " + "0");
		}
		if (end > arr.length) {
			throw new IllegalArgumentException("end:" + end + " > " + "arr.length");
		}
		double max = arr[begin + 1];
		for (int i = begin + 1; i < end; i++) {

			if (arr[begin + 1] < arr[i]) {
				double t = arr[begin + 1];
				arr[begin + 1] = arr[i];
				arr[i] = t;
				max = arr[begin + 1];
			}

		}
		return max;
	}

}

public class fivethree {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		double[] arr = new double[n];

		for (int i = 0; i < arr.length; i++) {
			double num = input.nextDouble();
			arr[i] = num;
		}
		while (input.hasNextInt()) {
			int begin = input.nextInt();
			int end = input.nextInt();
			try {
				System.out.println(ArrayUtils.findMax(arr, begin, end));
			} catch (Exception e) {
				System.out.println(e);
			}

		}

		try {
			System.out.println(ArrayUtils.class.getDeclaredMethod("findMax", double[].class, int.class, int.class));
		} catch (Exception e1) {
		}
	}

}
